{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 505 1111]\n",
      " [1111 2525]]\n",
      "[[  10   14  100  140]\n",
      " [  14   20  140  200]\n",
      " [ 100  140 1000 1400]\n",
      " [ 140  200 1400 2000]]\n",
      "seconds: 0.005558013916015625\n",
      "seconds: 4.904746055603027\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "A = np.array([[1,2,10,20],\n",
    "              [3,4,30,40]])\n",
    "B = np.array([[1,3],\n",
    "              [2,4],\n",
    "              [10,30],\n",
    "              [20,40]])\n",
    "C = A@B\n",
    "D = B@A\n",
    "print(C)\n",
    "print(D)\n",
    "\n",
    "from numpy.random import randint\n",
    "import time\n",
    "num = 200\n",
    "A = randint(0,10,size=(num,num))\n",
    "B = randint(0,10,size=(num,num))\n",
    "start_time = time.time()\n",
    "C_1 = A@B\n",
    "end_time = time.time()\n",
    "print(f\"seconds: {end_time-start_time}\")\n",
    "\n",
    "C = np.zeros((num,num))\n",
    "start_time = time.time()\n",
    "for i in range(len(A)):\n",
    "    for j in range(len(B[0])):\n",
    "        for k in range(len(B)):\n",
    "            C[i,j] += A[i,k]*B[k,j]\n",
    "end_time = time.time()\n",
    "print(f\"seconds: {end_time-start_time}\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
